<?PHP
function OpenTPL_function_replace( $string, $search, $replace ) {
    if( ! function_exists( 'mb_str_replace' ) ) {
        function mb_str_replace( $needle, $replacement, $haystack ) {
            $needle_len = mb_strlen( $needle );
            $replacement_len = mb_strlen( $replacement );
            $pos = mb_strpos( $haystack, $needle, 0 );
            while ( $pos !== FALSE ) {
                $haystack = mb_substr( $haystack, 0, $pos ) . $replacement . mb_substr( $haystack, $pos + $needle_len );
                $pos = mb_strpos( $haystack, $needle, $pos + $replacement_len );
            }
            return $haystack;
        }
    }
    if ( function_exists( 'mb_substr' ) ) {
        return mb_str_replace( $search, $replace, $string );
    } else {
        return str_replace( $search, $replace, $string );
    }
}
?>